package com.demo.eventbus.service;

import com.google.common.eventbus.EventBus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 描述：
 * 作者 张超
 * 时间 2018/9/29
 * 项目 springboot-demo v1.0
 * 版本 v1.0
 */
@Service
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserService {

    private final EventBus eventBus;

    private final EventListener eventListener;
    private User user;

    public void send() {
        User user = new User();
        user.setAge(11);
        eventBus.register(eventListener);
        eventBus.post(user);
    }
}
